package com.water.camera.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.water.camera.databinding.DialogDeleteImgBinding;

public class DeleteDlg extends FullScreenDlg {

    DialogDeleteImgBinding binding;
    String msg;

    public DeleteDlg setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DialogDeleteImgBinding.inflate(inflater, container, false);
        if (!TextUtils.isEmpty(msg)) {
            binding.tvTitle.setText(msg);
        }
        binding.tvDelete.setOnClickListener(v -> dismiss(true, 0));
        binding.tvCancel.setOnClickListener(v -> dismiss());
        return binding.getRoot();
    }

    @Override
    protected int getHeight() {
        getDialog().getWindow().setGravity(Gravity.BOTTOM);
        return ViewGroup.LayoutParams.WRAP_CONTENT;
    }
}
